package com.tdcoding.chat.helper;

import java.util.Properties;

public class PropertyHelper {

	public String getString(Properties properties,String name) {
		return properties.getProperty(name, "");
	}

	public int getInt(Properties properties,String name, int defaultValue) {
		String val = properties.getProperty(name);
		return (val == null || val.isEmpty()) ? defaultValue : Integer.parseInt(val);
	}

	public long getLong(Properties properties,String name) {
		String val = properties.getProperty(name);
		return (val == null || val.isEmpty()) ? -1 : Integer.parseInt(val);
	}

	public float getFloat(Properties properties,String name) {
		String val = properties.getProperty(name);
		return (val == null || val.isEmpty()) ? -1 : Float.parseFloat(val);
	}

	public double getDouble(Properties properties,String name) {
		String val = properties.getProperty(name);
		return (val == null || val.isEmpty()) ? -1 : Double.parseDouble(val);
	}

	public byte getByte(Properties properties,String name) {
		String val = properties.getProperty(name);
		return (val == null || val.isEmpty()) ? null : Byte.parseByte(val);
	}

}
